server {
    listen      80;
    server_name  {{ item.domain }} ;
    root {{ item.path }};

    index index.html index.php;

    if ($request_method = HEAD) {
        return 200;
    }


    access_log  /var/log/nginx/{{ item.name }}_access.log main;
    error_log  /var/log/nginx/{{ item.name }}_error.log;

    location / {
        index  index.php index.html;
        try_files $uri $uri/ /index.php?$query_string;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    #location = /50x.html {
    #    root   /usr/share/nginx/html;
    #}

    location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
        #expires定义用户浏览器缓存的时间为7天，如果静态页面不常更新，可以设置更长，这样可以节省带宽和缓解服务器的压力
        rewrite ^/(.*)$ http://static.yicuicui.com/{{ item.name }}/$1 permanent; #若改 permanent 为 redirect ； 则发生的是 302 跳转     
    }

    location ~ \.php$ {
        fastcgi_pass   {{ item.servers }}_servers;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ /\.ht {
        deny  all;
    }
}